package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArcDestroy;
import com.hiultra.archive.service.IArcDestroyService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 销毁Controller
 * 
 * @author ls
 * @date 2023-09-02
 */
@Api(tags="销毁Controller")
@RestController
@RequestMapping("/archive/destroy")
public class ArcDestroyController extends BaseController
{
    @Autowired
    private IArcDestroyService arcDestroyService;

    /**
     * 查询销毁列表
     */
    @ApiOperation(value = "查询销毁列表", notes = "查询销毁列表")
    @PreAuthorize("@ss.hasPermi('archive:destroy:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcDestroy arcDestroy)
    {
        startPage();
        List<ArcDestroy> list = arcDestroyService.selectArcDestroyList(arcDestroy);
        return getDataTable(list);
    }

    /**
     * 导出销毁列表
     */
    @ApiOperation(value = "导出销毁列表", notes = "导出销毁列表")
    @PreAuthorize("@ss.hasPermi('archive:destroy:export')")
    @Log(title = "销毁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcDestroy arcDestroy)
    {
        List<ArcDestroy> list = arcDestroyService.selectArcDestroyList(arcDestroy);
        ExcelUtil<ArcDestroy> util = new ExcelUtil<ArcDestroy>(ArcDestroy.class);
        util.exportExcel(response, list, "销毁数据");
    }

    /**
     * 获取销毁详细信息
     */
    @ApiOperation(value = "获取销毁详细信息", notes = "获取销毁详细信息")
    @PreAuthorize("@ss.hasPermi('archive:destroy:query')")
    @GetMapping(value = "/{destroyId}")
    public AjaxResult getInfo(@PathVariable("destroyId") Long destroyId)
    {
        return AjaxResult.success(arcDestroyService.selectArcDestroyByDestroyId(destroyId));
    }

    /**
     * 新增销毁
     */
    @ApiOperation(value = "新增销毁", notes = "新增销毁")
    @PreAuthorize("@ss.hasPermi('archive:destroy:add')")
    @Log(title = "销毁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcDestroy arcDestroy)
    {
        return toAjax(arcDestroyService.insertArcDestroy(arcDestroy));
    }

    /**
     * 修改销毁
     */
    @ApiOperation(value = "修改销毁", notes = "修改销毁")
    @PreAuthorize("@ss.hasPermi('archive:destroy:edit')")
    @Log(title = "销毁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcDestroy arcDestroy)
    {
        return toAjax(arcDestroyService.updateArcDestroy(arcDestroy));
    }

    /**
     * 删除销毁
     */
    @ApiOperation(value = "删除销毁", notes = "删除销毁")
    @PreAuthorize("@ss.hasPermi('archive:destroy:remove')")
    @Log(title = "销毁", businessType = BusinessType.DELETE)
	@DeleteMapping("/{destroyIds}")
    public AjaxResult remove(@PathVariable Long[] destroyIds)
    {
        return toAjax(arcDestroyService.deleteArcDestroyByDestroyIds(destroyIds));
    }
}
